package com.ftg.shopping.member.controller;


import com.ftg.shopping.config.LayuiPage;
import com.ftg.shopping.member.entity.sp_memberinfo;
import com.ftg.shopping.member.service.MemberService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(description ="会员管理")
@RestController
@RequestMapping("/api/member")
public class MemberController {

    @Autowired
    MemberService memberService;

    @ApiOperation("查看会员全部数据")
    @GetMapping("/list")
    public LayuiPage<sp_memberinfo> list(){
        return memberService.list();
    }


    @ApiOperation("按主键查看一个会员")
    @PutMapping("/findone/{id}")
    public sp_memberinfo findone(int id){
        return memberService.findone(id);
    }

    @ApiOperation("添加一个会员")
    @PostMapping("/insert")
    public int savemem(sp_memberinfo m){
        return memberService.savemem(m);
    }

    @ApiOperation("更改一个角色")
    @PostMapping("/update")
    public int updatemem(sp_memberinfo m){
        return memberService.updatemem(m);
    }
    @ApiOperation("删除一个会员")
    @DeleteMapping("/delete")
    public  int deletemem( int id){
        return memberService.deletemem(id);
    }

    @ApiOperation("删除多个会员")
    @DeleteMapping("/delete/{ids}")
    public int deletememids(@PathVariable List<Integer> ids){
        return memberService.deletememids(ids);
    }

    @ApiOperation("分页查询带模糊")
    @GetMapping("/page1")
    public LayuiPage<sp_memberinfo> list1(@RequestParam int page,@RequestParam int limit,@RequestParam(required = false) String id  ){
        return memberService.page1(page,limit,id);

    }










}
